<template>
  <div>
    <v-table :header="header" :tableList="tableData"></v-table>
  </div>
</template>

<script>
import vTable from "../../components/Table/index";
import bus from "./bus.js";

export default {
  data() {
    return {
      header: [
        // { prop: "patientName", label: "姓名" },
        {
          prop: "patientName",
          label: "姓名",
          render: (h, data) => {
            // render函数元素显示label两种方式 domProps || data.row.userName
            // render函数设置标签props 绑定事件on
            return h(
              "el-button",
              {
                domProps: {
                  innerHTML: data.row.patientName,
                },
                props: {
                  type: "text",
                },
                on: {
                  click: () => {
                    this.getDetails(data.row);
                  },
                },
              },
              // data.row.patientName
            );
          },
        },
        { prop: "phone", label: "手机号" },
        { prop: "departmentName", label: "科室" },
        { prop: "doctorName", label: "医生" },
        { prop: "hospitalNum", label: "住院号" },
        { prop: "inHospitalTime", label: "入院时间" },
        { prop: "outHospitalTime", label: "出院时间" },
        { prop: "sugarNum", label: "入院血糖" },
        { prop: "outSugarNum", label: "出院血糖" },
        {
          label: "操作",
          render: (h, data) => {
            return (
              <el-button
                type="text"
                onClick={() => {
                  this.getDetails(data.row);
                }}
              >
                查看
              </el-button>
            );
          },
        },
      ],
      tableData: [],
    };
  },
  mounted() {
    this.getOutInfoList();
  },
  methods: {
    // 获取所有出院数据
    getOutInfoList() {
      bus.$on("outInfoList", (data) => {
        if (data.code == 200) {
          this.tableData = data.data.data;
        } else {
          this.tableData = [];
        }
      });
    },
    getDetails(row) {
      this.$router.push({ path: "/patientDetails", query: { id: row.id ,type:2} });
    },
  },
  components: {
    vTable,
  },
};
</script>

<style>
</style>